package com.bdqn.servlet.Department;

import com.bdqn.entity.Department;
import com.bdqn.service.DepartmentService;
import com.bdqn.service.Impl.DepartmentServiceImpl;
import com.bdqn.util.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "FindDepServlet",urlPatterns = "/findDep")
public class FindDepServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        DepartmentService service = new DepartmentServiceImpl();
        List<Department> list = service.findAll();
        JSON.writeAsString(list,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
